package com.shop.front.vo.store;

import com.alibaba.fastjson.annotation.JSONField;
import com.shop.jpa.domain.BaseDomain;
import com.shop.util.IdSignUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

@ApiModel("StoreCartVo 购物车")
@Data
public class StoreCartVo extends BaseDomain implements Serializable {

    @ApiModelProperty(value = "id", hidden = true)
    @Id
    @JSONField(serialize=false)
    private Long id;

    @ApiModelProperty(value = "product_id", hidden = true)
    @Column(name = "product_id")
    @JSONField(serialize=false)
    private Long productId;

    @ApiModelProperty(value = "product_id", hidden = true)
    @Column(name = "product_attr_value_id")
    @JSONField(serialize=false)
    private Long productAttrValueId;

    /**
     * 数量
     */
    @ApiModelProperty("数量")
    @Column(name = "cart_num")
    private Integer cartNum;

    /**
     * 商品名称
     */
    @ApiModelProperty("商品名称")
    @Column(name = "store_name")
    private String storeName;

    /**
     * 商品简介
     */
    @ApiModelProperty("商品简介")
    @Column(name = "store_info")
    private String storeInfo;

    /**
     * 是否拼团商品 0 未开启 1已开启
     */
    @ApiModelProperty("是否拼团商品 0 未开启 1已开启")
    @Column(name = "is_pink")
    private Integer isPink;

    /**
     * 商品属性索引值 (attr_value|attr_value[|....])
     */
    @ApiModelProperty("商品属性索引值 (attr_value|attr_value[|....])")
    @Column(name = "suk")
    private String suk;

    /**
     * 属性对应的库存
     */
    @ApiModelProperty("属性对应的库存")
    @Column(name = "stock")
    private Integer stock;

    /**
     * 属性金额
     */
    @ApiModelProperty("属性金额")
    @Column(name = "price")
    private BigDecimal price;

    /**
     * 原价
     */
    @ApiModelProperty("拼团价")
    @Column(name = "pink_price")
    private BigDecimal pinkPrice;

    /**
     * 原价
     */
    @ApiModelProperty("原价")
    @Column(name = "origin_price")
    private BigDecimal originPrice;

    /**
     * 是否积分商品
     */
    @ApiModelProperty("是否积分商品")
    @Column(name = "is_integral")
    private Integer isIntegral;

    /**
     * 积分价格
     */
    @ApiModelProperty("积分价格")
    @Column(name = "integral_price")
    private BigDecimal integralPrice;

    /**
     * 积分价格
     */
    @ApiModelProperty("需要积分")
    @Column(name = "integral")
    private BigDecimal integral;

    /**
     * 图片
     */
    @ApiModelProperty("图片")
    @Column(name = "image")
    private String image;


    @ApiModelProperty("产品ID")
    @Transient
    private String productSign;
    public String getProductSign() {
        return IdSignUtil.doSign(this.productId);
    }

    @ApiModelProperty("产品规格ID")
    @Transient
    private String productAttrValueSign;
    public String getProductAttrValueSign() {
        return IdSignUtil.doSign(this.productAttrValueId);
    }

}
